<template>
  <div>
    <div class="table">
      <el-table :data="baselogData" style="width: 100%">
        <el-table-column type="index" label="序号" align="center" width="55" />
        <el-table-column prop="realname" label="访问人真实姓名" align="center" />
        <el-table-column prop="method" label="访问方式" align="center" />
        <el-table-column prop="content" label="访问路径" align="center" />
        <el-table-column prop="logTIme" :formatter="fmt" label="访问时间" align="center" />
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination
        :current-page="currentPage"
        :page-sizes="[2, 5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/locale/af.min.js"></script>
<script>
import { get, post } from "@/utils/request";
import moment from "moment";
export default {
  data() {
    return {
      //返回的数据
      baselogData: [],
      currentPage: 1,
      pageSize: 10,
      total: 10,
      time:"",
    };
  },
  computed: {},
  methods: {
    async GetbaselogData() {
      // 获取参数
      let data = {
        page: this.currentPage,
        pageSize: this.pageSize,
      };
      // 通过对应的参数发送网络请求 获取产品数组数据
      let res = await get("/baseLog/pageQuery", data);
      // 将data中的产品数组 进行赋值
      this.baselogData = res.data.list;
      // 页面总数据条数 赋值
      this.total = res.data.total;

    },
    handleSizeChange(val) {
      // 将每页要展示的数据的条数 进行一个更新
      this.pageSize = val;
      // 将当前的页数 重置到第一页
      this.currentPage = 1;
      // 重新调用获取所有产品数据的方法
      this.GetbaselogData();
    },
    handleCurrentChange(val) {
      // 将当前页数 与 分页插件动态点击控制的页数相绑定
      this.currentPage = val;
      // 重新调用获取所有产品数据的方法
      this.GetbaselogData();
    },
    fmt(row, column) {
      return moment(row.logTime).format("YYYY-MM-DD HH:mm:ss");
    },

  },

  created() {
    this.GetbaselogData();
  },
  mounted() {

  },
   filters: {
    dateFMT(str) {
      // var res = moment(str).format('YYYY-MM-DD HH:mm:ss');
      // return res;
      return moment(str).format("YYYY-MM-DD HH:mm:ss");
    },
   },
};
</script>
<style scoped>
  .pagination{
     position: fixed;
     bottom: 40px;
     right: 10px;
  }

</style>
